package mobi.yuanshen.exception;

import mobi.yuanshen.utils.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
//    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 设置响应状态码
    public Result handler (Exception e) {
        e.printStackTrace();
        System.out.println("GlobalExceptionHandler.handler" + "捕获到了异常" + e.getMessage());
        return Result.error("操作失败，请练习管理员解决");
    }
}
